//
// This file is part of cpp-lib, a library of C++ functions and classes.
// Cpp-lib is copyright (C) 2004 and onwards, The CPL Interest Group.
// 
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or (at
// your option) any later version.
// 
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
// General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public License
// along with this library (see the file COPYING); if not, write to the
// Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
// 02111-1307  USA
//
// $Id$
//

#include <iostream>
#include <stdexcept>
#include <exception>
#include <string>
#include <memory>

#include <cstdlib>
#include <cassert>

#include "cpp-lib/command_line.h"
#include "cpp-lib/util.h"


using namespace cpl::util ;

namespace {

const opm_entry options[] = {

  opm_entry( "list"       , opp( false , 'l' ) ) ,
  opm_entry( "output"     , opp( true  , 'o' ) ) ,
  opm_entry( "fullscreen" , opp( false , 'f' ) ) ,
  opm_entry( "help"       , opp( false , 'h' ) )

} ;


void usage( std::string const& name ) {

  std::cerr << "usage: " << name << " [ options ]\n"
"-l, --list           List some values.\n"
"-o, --output <file>  Write output to <file>.\n"
"-f, --fullscreen     Fullscreen mode.\n"
"-h, --help           Display this message.\n" ;

}


} // anonymous namespace



int main( int const argc , char const * const * const argv ) {

  try {

  if( argc == 1 ) 
  { std::cout << "Type " << argv[ 0 ] << " --help for help.\n" ; return 0 ; }

  command_line cl( options , options + size( options ) , argv ) ;

  if( cl.is_set( "help" ) ) { usage( argv[ 0 ] ) ; return 0 ; }

  if( cl.is_set( "fullscreen" ) )
  { std::cout << "Fullscreen mode.\n" ; }

  if( cl.is_set( "list" ) ) 
  { std::cout << "List some values...\n" ; }

  if( cl.is_set( "output" ) ) 
  { std::cout << "Write output to " << cl.get_arg( "output" ) << '\n' ; }


  } // global try
  catch( std::runtime_error const& e )
  { std::cerr << e.what() << '\n' ; return 1 ; }

  return 0 ;

}
